

#import "OCBaseViewController.h"

@interface OCBaseViewController ()

@end

@implementation OCBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = k_Color_ViewDefault;
    self.edgesForExtendedLayout = UIRectEdgeNone;
//    self.edgesForExtendedLayout = UIRectEdgeAll;
    
    self.hbd_barTintColor = k_Color_ViewDefault;
    
    self.hbd_barStyle = UIBarStyleDefault;
    self.hbd_titleTextAttributes = @{NSFontAttributeName: kNavigationBarTitleFont, NSForegroundColorAttributeName:k_Color_333333};
    self.hbd_barShadowHidden = YES;
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.backButton = backBtn;
    [backBtn setImage:[UIImage imageNamed:@"base_back_icon"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(onClickBack:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    if (self.navigationController.viewControllers.count > 1) {
        backBtn.hidden = NO;
    } else {
        backBtn.hidden = YES;
    }
}

- (UIModalPresentationStyle)modalPresentationStyle {
    return UIModalPresentationFullScreen;
}

- (void)dealloc {
    [self.view endEditing:YES];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    DEBUGLOG(@"%@-------dealloc", [self class]);
}

#pragma mark ------- Public Methods -------

- (void)fragmentUI_ViewSet { }

- (void)apiFailed:(NSString *)msg {
    [OCProgress_HUD showErrorWithStatus:msg];
}

/// 可重写此方法
- (void)onClickBack:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)setWhiteBackBtn {
    [self.backButton setImage:@"base_whiteback_icon".image forState:UIControlStateNormal];
}

@end
